package com.user.controller;

import com.user.dao.dish.CreatOrUpdateDish;
import com.user.dao.dish.QueryPageDish;
import com.user.service.DishService;
import com.user.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;


/**
 * @Author : Yu
 * @Date 2023/12/29 11:11
 */

@RestController
@RequestMapping("/dish")
public class DishController {

    @Resource
    private DishService dishService;

    //    @SaCheckRole("admin")
    @PostMapping("/saveOrUpdateDish")
    public R saveOrUpdateDish(@Valid @RequestBody CreatOrUpdateDish dish) {
        return dishService.saveOrUpdateDish(dish);
    }

    @PostMapping("/getDish")
    public R getDish(@RequestBody QueryPageDish dish) {
        return dishService.getPageDish(dish);
    }

    @PostMapping("/getDishByIds")
    public R getDishByIds(@RequestBody List<Integer> ids) {
        return dishService.getDishById(ids);
    }

    @GetMapping("/getDishPhoto")
    public R getDishPhoto(@RequestParam Integer id) {
        return dishService.getDishPhoto(id);
    }

    @DeleteMapping("/delete")
    public R deleteDishById(@RequestParam Integer id) {
        return dishService.deleteDishById(id);
    }
}
